#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
//int x = 5, y = 7;
//void swap()
//{
//	int z;
//	z = x;
//	x = y;
//	y = z;
//}
//int main()
//{
//	int x = 3, y = 8;
//	swap();
//	printf("%d,%d\n",x, y);
//	return 0;
//}

//int main()
//{
//	double x[5] = { 2.0,4.0,6.0,7.0,8.0 };
//	char c2[] = { '\x10','\xa','\8' };
//	char c1[] = { '1','2','3','3','5' };
//	int y[5 + 3] = { 0,1,2,3,4,4,5 };
//
//	return 0;
//}
//#include<math.h>
//static int arr[100000];
//int* printNumbers(int n, int* returnSize) {
//    // write code here
//    int a, i;
//    a = pow(10, n);
//    for (i = 1; i <= a - 1; i++)
//    {
//        arr[i - 1] = i;
//    }
//    *returnSize = a - 1;
//    return arr;
//
//}
//int main()
//{
//    int n, returnSize;
//    
//    scanf("%d", &n);
//    *printNumbers(n, &returnSize);
//    for (int i = 0; i < returnSize; i++)
//    {
//        printf("%d ", arr[i]);
//    }
//    return 0;
//}
#include <stdio.h>
int num(int year, int mon, int day)
{
    int Feb, ret = 0;
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0  )
        Feb = 29;
    else
        Feb = 28;
    switch (mon-1)
    {
    case 1: ret = 31;
        break;
    case 2: ret = Feb+31;
        break;
    case 3: ret = 31+ Feb + 31;
        break;
    case 4: ret = 30+ 31 + Feb + 31;
        break;
    case 5: ret = 31+ 30 + 31 + Feb + 31;
        break;
    case 6: ret = 30+ 31 + 30 + 31 + Feb + 31;
        break;
    case 7: ret = 31+ 30 + 31 + 30 + 31 + Feb + 31;
        break;
    case 8: ret = 31+ 31 + 30 + 31 + 30 + 31 + Feb + 31;
        break;
    case 9: ret = 30+ 31 + 31 + 30 + 31 + 30 + 31 + Feb + 31;
        break;
    case 10: ret = 31+ 30 + 31 + 31 + 30 + 31 + 30 + 31 + Feb + 31;
        break;
    case 11: ret = 30+ 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + Feb + 31;
        break;
    case 12: ret = 31+ 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + Feb + 31;
        break;
    }
    ret += day;
    return ret;
}

int main() {
    int year, mon, day;
    scanf("%d%d%d", &year, &mon, &day);
    int ret = num(year, mon, day);
    printf("%d\n", ret);
    return 0;
}